<template>
  <div class="data">
    <div class="title">库存查询</div>
    <div class="content">
      <span>
        商品号:
        <input placeholder="请输入" v-model="value" />
      </span>
      <span>
        变动类型:
        <a-select placeholder="请选择" style="width: 120px; margin-left: 12px; font-size: 14px">
          <a-select-option value="jack">类别一</a-select-option>
          <a-select-option value="lucy">类别一</a-select-option>
        </a-select>
      </span>
      <a-button style="margin-left: 59px" type="primary" @click="getgoods">查询</a-button>
      <a-button style="margin-left: 21px" type="primary" @click="add">添加商品</a-button>
      <!-- <a-button style="margin-left: 23px" type="primary" @click="out">出库</a-button> -->
    </div>
    <div>
      <!-- <el-button type="text" @click="update">新增</el-button> -->
      <el-dialog title="更改商品信息" :visible.sync="dialogFormVisible">
        <el-form :model="form">
          <el-form-item label="商品名称" :label-width="formLabelWidth">
            <el-input v-model="form.name" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="单价" :label-width="formLabelWidth">
            <el-input v-model="form.price" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="销售总数" :label-width="formLabelWidth">
            <el-input type="number" v-model="form.total" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="出版社" :label-width="formLabelWidth">
            <el-input v-model="form.press" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="库存量" :label-width="formLabelWidth">
            <el-input type="number" v-model="form.stock" autocomplete="off"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="upfrom">确 定</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import { getGoods } from "@/api/data";
// import bus from "../views/EventBus.js";

export default {
  name: "Query",
  data() {
    return {
      value: "",
      detailData: {},
      // detailData: [],
      dialogTableVisible: false,
      dialogFormVisible: false,
      form: {
        stock: 0,
        press: "",
        total: 1,
        price: 0,
        name: ""
      },
      formLabelWidth: "120px"
    };
  },
  methods: {
    async getgoods() {
      const id = this.value;
      if (id != "") {
        const data = await getGoods(id);
        this.detailData = data;
        console.log(this.detailData);
        // bus.$emit("list", [this.detailData]);
      } else {
        alert("商品号错误！！");
      }
    },
    add() {
      this.dialogFormVisible = true;
    }
  }
};
</script>

<style>
.data {
  padding: 50px 0;
}
.title {
  width: 80px;
  height: 30px;
  margin: 0 0 23px 53px;
  font-weight: bold;
  font-size: 20px;
}

.content {
  margin-left: 114px;
  font-size: 18px;
  display: flex;
  justify-content: space-around;
}
.content input {
  width: 254px;
  height: 29px;
  margin-left: 12px;
  border: rgba(217, 217, 217, 1) solid 1px;
  border-radius: 2px;
  font-size: 14px;
  color: rgba(166, 166, 166, 1);
}
</style>